﻿<PropertyPanels:GadgetPropertiesPanelBase x:Class="EpiDashboard.Controls.GadgetProperties.FrequencyProperties"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:Controls="clr-namespace:EpiDashboard.Controls"
             xmlns:PropertyPanels="clr-namespace:EpiDashboard.Controls.GadgetProperties"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800" Loaded="UserControl_Loaded" Style="{DynamicResource PropertiesPanelStyle}">
    <PropertyPanels:GadgetPropertiesPanelBase.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../StyleDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </PropertyPanels:GadgetPropertiesPanelBase.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="400" Width=".33*" />
            <ColumnDefinition Width="30" />
            <ColumnDefinition Width=".66*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel Grid.Column="0" Grid.RowSpan="3" x:Name="panelSidebar" Background="{StaticResource PrimaryAccentColorLight}">
            <Label x:Name="lblConfigExpandedTitle" FontWeight="Light" Foreground="White" FontSize="56" Margin="0, 0, 0, 10">Frequency</Label>

            <Controls:SettingsToggleButton x:Name="tbtnVariables" Title="Variables" Description="Select the column for the frequency." IsChecked="True" Checked="tbtnVariables_Checked"/>
            <!--<Controls:SettingsToggleButton x:Name="tbtnSorting" Title="Sorting and Grouping" Description="Set a sort order and create list groups." IsChecked="False" Checked="tbtnSorting_Checked"/>-->
            <Controls:SettingsToggleButton x:Name="tbtnDisplay" Title="Display" Description="Change display options." IsChecked="False" Checked="tbtnDisplay_Checked"/>
            <Controls:SettingsToggleButton x:Name="tbtnFilters" Title="Filters" Description="Set data filters for this gadget." IsChecked="False" Checked="tbtnFilters_Checked"/>

        </StackPanel>
        
        <StackPanel x:Name="panelVariables" Grid.Column="2" Margin="0, 0, 10, 0" Visibility="Visible">
            <Label Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10">Variables</Label>

            <TextBlock x:Name="tblockMainVariable">Frequency of:</TextBlock>
            <ComboBox x:Name="cbxField" Width="216" HorizontalAlignment="Left" Height="28" SelectionChanged="cbxField_SelectionChanged" />
            
            <StackPanel Height="12" />
            
            <TextBlock x:Name="tblockWeightVariable">Weight:</TextBlock>
            <ComboBox x:Name="cbxFieldWeight" Width="216" HorizontalAlignment="Left" Height="28" SelectionChanged="cbxFieldWeight_SelectionChanged" />
            
            <Label Style="{StaticResource PropertiesSubHeading}" Margin="0, 26, 0, 10">Sorting and Grouping</Label>
            <TextBlock x:Name="tblockSortMethod">Sort Method:</TextBlock>
            <CheckBox x:Name="checkboxSortHighLow" Style="{StaticResource PropertiesPanelCheckbox}" Content="Sort high to low" HorizontalAlignment="Left" IsChecked="true">
                <!--<CheckBox.ToolTip>
                    <StackPanel>
                        <Label FontWeight="Bold">Sort High to Low</Label>
                        <TextBlock 
                                               Padding="10" Background="Transparent" TextWrapping="WrapWithOverflow" Width="200">
                                        Determines if the output is sorted from highest frequency to lowest frequency. If unchecked, the output
                        will be sorted alphabetically.</TextBlock>
                    </StackPanel>
                </CheckBox.ToolTip>-->
            </CheckBox>
            <TextBlock x:Name="tblockStrataVariable">Stratify by:</TextBlock>
            <ScrollViewer x:Name="scrollViewerStrataProperties" VerticalAlignment="Stretch" Height="400" >
                <StackPanel>
                    <ListBox SelectionMode="Multiple" Name="lbxFieldStrata" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SelectionChanged="lbxFieldStrata_SelectionChanged" />
                </StackPanel>
            </ScrollViewer>
        </StackPanel>
        <!--<StackPanel x:Name="panelSorting" Grid.Column="2"  Margin="0, 0, 10, 0" Visibility="Collapsed">
            <Label Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10">Sorting and Grouping</Label>

            <Label Style="{StaticResource PropertiesSubHeading}" Margin="0, 0, 0, 4">Grouping</Label>
            <Label>Stratify by:</Label>
            <Label Style="{StaticResource PropertiesSubHeading}" Margin="0, 30, 0, 4">Sorting</Label>         
        </StackPanel>-->

        <StackPanel x:Name="panelDisplay" Grid.Column="2" VerticalAlignment="Stretch" Margin="0, 0, 10, 0" Visibility="Collapsed">
            <Label Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10">Display</Label>

            <ScrollViewer x:Name="scrollViewerProperties" Height="700">
                <StackPanel>
                    <Label Style="{StaticResource PropertiesSubHeading}" Margin="0,0, 0, 10">Title and Description</Label>
                    <Label x:Name="tblockTitle" VerticalAlignment="Bottom" HorizontalAlignment="Left" Content="Gadget title:" />
                    <TextBox x:Name="txtTitle" Width="360" HorizontalAlignment="Left"></TextBox>

                    <Label x:Name="tblockDesc" VerticalAlignment="Bottom" HorizontalAlignment="Left" Content="Gadget description:" />
                    <TextBox x:Name="txtDesc" Width="360" AcceptsReturn="True" Height="128" HorizontalAlignment="Left" TextWrapping="Wrap"></TextBox>

                    <Label Style="{StaticResource PropertiesSubHeading}" Margin="0, 26, 0, 10">Output Options</Label>
                    <CheckBox x:Name="checkboxAllValues" Style="{StaticResource PropertiesPanelCheckbox}" Content="Display all list values" Visibility="Visible" IsEnabled="true" />
                    <CheckBox x:Name="checkboxCommentLegalLabels" Style="{StaticResource PropertiesPanelCheckbox}" Content="Display list labels" Visibility="Visible" IsEnabled="true" />
                    <CheckBox x:Name="checkboxIncludeMissing" Style="{StaticResource PropertiesPanelCheckbox}" Content="Include missing values" IsChecked="True" />
                    <!--<CheckBox x:Name="checkboxShowNulls" Style="{StaticResource PropertiesPanelCheckbox}" Content="Show missing representation" IsChecked="True" />-->

                    <CheckBox x:Name="checkboxUsePrompts" Style="{StaticResource PropertiesPanelCheckbox}" Content="Use field prompts" Visibility="Visible" IsEnabled="true">
                        <!--<CheckBox.ToolTip>
                            <StackPanel>
                                <Label FontWeight="Bold">Shows labels</Label>
                                <TextBlock 
                                               Padding="10" Background="Transparent" TextWrapping="WrapWithOverflow" Width="200" >
                                    Shows field prompts instead of the field names. Not applicable to variables that are not Epi Info 7 fields.
                                        </TextBlock>
                            </StackPanel>
                        </CheckBox.ToolTip>-->
                    </CheckBox>

                    <CheckBox x:Name="checkboxDrawBorders" Style="{StaticResource PropertiesPanelCheckbox}" Content="Draw borders" Visibility="Visible" IsEnabled="true" />
                    <CheckBox x:Name="checkboxDrawHeader" Style="{StaticResource PropertiesPanelCheckbox}" Content="Draw header row" Visibility="Visible" IsEnabled="true" />
                    <CheckBox x:Name="checkboxDrawTotal" Style="{StaticResource PropertiesPanelCheckbox}" Content="Draw total row" Visibility="Visible" IsEnabled="true" />

                    <Label x:Name="tblockPrecision" VerticalAlignment="Bottom" HorizontalAlignment="Left" Content="Decimals to display:" />
                    <ComboBox x:Name="cbxFieldPrecision" HorizontalAlignment="Left" Width="45" SelectedIndex="2">
                        <ComboBoxItem>0</ComboBoxItem>
                        <ComboBoxItem>1</ComboBoxItem>
                        <ComboBoxItem>2</ComboBoxItem>
                        <ComboBoxItem>3</ComboBoxItem>
                        <ComboBoxItem>4</ComboBoxItem>
                    </ComboBox>

                    <TextBlock x:Name="tblockPercentBarData" HorizontalAlignment="Left" TextAlignment="Center" Text="Percent bar display mode:" Margin="0,5,0,0" Visibility="Collapsed"  />
                    <ComboBox x:Name="cmbPercentBarMode" SelectedIndex="0" Visibility="Collapsed">
                        <ComboBoxItem>Bar only</ComboBoxItem>
                        <ComboBoxItem>Bar and percent</ComboBoxItem>
                    </ComboBox>

                    <TextBlock x:Name="tblockRows" HorizontalAlignment="Left" TextAlignment="Center" Text="Maximum rows to display:"  Margin="0,5,0,0"  />
                    <TextBox x:Name="txtRows" Width="100" />

                    <TextBlock x:Name="tblockBarWidth" HorizontalAlignment="Left" TextAlignment="Center" Margin="0,5,0,0" >Maximum width of percent bar:</TextBlock>
                    <TextBox x:Name="txtBarWidth"  Width="100"/>

                    <!--<TextBlock x:Name="tblockOutputColumns" Margin="0,5,0,0" >Output columns to display:</TextBlock>-->
                    <Label Style="{StaticResource PropertiesSubHeading}" Margin="0, 26, 0, 10">Output Columns To Display</Label>
                    <StackPanel>
                        <CheckBox x:Name="checkboxColumnFrequency" Style="{StaticResource PropertiesPanelCheckbox}" Content="Frequency" IsChecked="True" />
                        <CheckBox x:Name="checkboxColumnPercent" Style="{StaticResource PropertiesPanelCheckbox}" Content="Percent" IsChecked="True" />
                        <CheckBox x:Name="checkboxColumnCumulativePercent" Style="{StaticResource PropertiesPanelCheckbox}" Content="Cumulative percent" IsChecked="True" />
                        <CheckBox x:Name="checkboxColumn95CILower" Style="{StaticResource PropertiesPanelCheckbox}" Content="95% CI lower" IsChecked="True" />
                        <CheckBox x:Name="checkboxColumn95CIUpper" Style="{StaticResource PropertiesPanelCheckbox}" Content="95% CI upper" IsChecked="True" />
                        <CheckBox x:Name="checkboxColumnPercentBars" Style="{StaticResource PropertiesPanelCheckbox}" Content="Percent bars" IsChecked="True" />
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
        </StackPanel>

        <StackPanel x:Name="panelFilters" Grid.Column="2"  Margin="0, 0, 10, 0" Visibility="Collapsed">
            <Label Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10">Data Filters</Label>
            <Label>Note: Any filters set here are applied to this gadget only.</Label>
        </StackPanel>
        
        <Button Style="{StaticResource CloseButtonStyle}" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8" Click="CloseButton_Click" />

        <DockPanel Grid.ColumnSpan="3" Grid.Row="1">
            <Button x:Name="btnCancel" DockPanel.Dock="Right" HorizontalAlignment="Right" Margin="8" Width="134" Height="42" Click="btnCancel_Click">Cancel</Button>
            <Button x:Name="btnOK" DockPanel.Dock="Right" HorizontalAlignment="Right" Margin="8" Width="134" Height="42" Click="btnOK_Click">OK</Button>
        </DockPanel>
    </Grid>
</PropertyPanels:GadgetPropertiesPanelBase>
